#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
    char routingKey[128] = "mem.localhost.192.168.31.1";
    char hostname[128] = {0};
    char *indStart = strchr(routingKey, '.');
    char *indEnd = strchr(indStart + sizeof(char), '.');
    printf("%s\n", indStart);
    printf("%s\n", indEnd);
    strncpy(hostname, indStart + sizeof(char), indEnd - indStart - 1);
    printf("%s\n", hostname);
    printf("\n");
    char *indIp = NULL;
    // for (int i = 0; i < 2; i++) {
    //     indIp = strchr(indIp, '.');
    //     printf("%s\n", indIp + 1);
    // }
    indIp = strchr(routingKey, '.');
    printf("%s\n", indIp + 1);
    indIp += 1;
    indIp = strchr(indIp, '.');
    printf("%s\n", indIp + 1);

    return 0;
}